/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-16 20:15:00
 * @LastEditTime: 2021-08-16 20:25:25
 * @LastEditors: changqing
 * @Usage: 
 */
// Cold Observable每次订阅后就只会有一个观察者， 下一个观察者要进行订阅时是一次新的数据流程，因此Cold Observable与observer是一对一关系
var {Observable} = require('rxjs');

const source$ = new Observable(subscriber => {
  console.log('stream 开始');
  subscriber.next(1);
  subscriber.next(2);
  subscriber.next(3);
  subscriber.next(4);
  console.log('steam 结束');
  subscriber.complete();
});
source$.subscribe(data => console.log(`Observable 第一次订阅: ${data}`));
// 1, 2, 3, 4
source$.subscribe(data => console.log(`Observable 第二次订阅: ${data}`));
// 1, 2, 3, 4